﻿using Base.Api.Models;
using Base.Api.Service;
using Common.AspNetCore;
using Common.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Base.Api.Controllers
{
    [Route("api/Login")]
    public class LoginController : ApiController
    {
        private readonly AuthLoginService authLoginService;

        public LoginController(IServiceProvider provider, AuthLoginService auth)
             : base(provider)
        {
            this.authLoginService = auth;
        }

        [HttpPost, Route("GetLoginInfo")]
        public async Task<ApiActionResult<LoginInfo>> GetLoginInfo([FromBody] LoginInfoRequest request)
        {
            return await SafeExecuteAsync<LoginInfo>(async (param) =>
           {
               return await this.authLoginService.GetLoginInfoAsync(request); 
           });
        }
    }
}
